{include file="public/header" /}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <fieldset id="searchFieldset_currentTableRenderId" class="table-search-fieldset">
                        <legend>条件搜索</legend>
                        <form class="layui-form layui-form-pane form-search">
                            <div class="layui-form-item layui-inline">
                                <label class="layui-form-label">名称</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="title" placeholder="客户/经理关键字"
                                        value="{:input('get.title')}" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item layui-inline">
                                <label class="layui-form-label">会员类型</label>
                                <div class="layui-input-inline">
                                  <select name="level">
                                    <option value="">请选择会员类型</option>
                                    {foreach $userauth as $v}
                                    <option value="{$v.id}" {if !empty(input('get.level')) &&
                                      input('get.level')==$v.id}selected{/if}>
                                      {$v.name}</option>
                                    {/foreach}
                                  </select>
                                </div>
                              </div>
                            <div class="layui-form-item layui-inline">
                                <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="sreach">搜索</button>
                            </div>
                        </form>
                    </fieldset>
                </div>
                <div class="layui-card-header">
                    <!-- <button class="layui-btn layui-btn-danger layui-btn-sm" onclick="delAll()">批量删除</button> -->
                    <a title="添加客户" onclick="open_add('添加客户','/user/user_edit')" href="javascript:;"
                        class="layui-btn layui-btn-sm">
                        添加客户
                    </a> 数据：<strong id="count">{$list->total()}</strong> 条
                </div>
                <div class="layui-card-body layui-table-body layui-table-main">
                    <table class="layui-table layui-form">
                        <thead>
                            <tr>
                                <th>
                                    <input type="checkbox" lay-filter="checkall" name="" lay-skin="primary">
                                </th>
                                <th>
                                    <div class="layui-table-cell">ID</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">收货地址</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">客户名称</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">客户类型</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">联系电话</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">登陆账号</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">创建时间</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">状态</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">客户经理</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">操作</div>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            {foreach $list as $v}
                            <tr>
                                <td>
                                    <input type="checkbox" name="id" value="{$v.id|default='0'}" lay-skin="primary">
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.id|default=''}</div>
                                </td>
                                <td>
                                    {if !empty($v.address)}
                                    姓名:{$v.address.name}<br />
                                    电话:{$v.address.mobile}<br />
                                    地址:{$v.address.province}{$v.address.city}{$v.address.area}{$v.address.address}<br />
                                    {else}无{/if}
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.name|default='--'}</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.userauth|default='--'}</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.phone|default='--'}</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.mobile|default='未添加'}</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.created|default='--'}</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.status_text|default=''}</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.jl|default='--'}</div>
                                </td>
                                <td class="layui-table-col-special">
                                    <div class="layui-table-cell">
                                        <a title="编辑" onclick="open_add('编辑','/user/user_edit?id={$v.id}')"
                                            href="javascript:;" class="layui-btn layui-btn-sm">
                                            编辑
                                        </a>
                                        <a title="收货地址" onclick="open_add('收货地址','/user/address?id={$v.id}')"
                                            href="javascript:;" class="layui-btn layui-btn-sm layui-btn-normal">
                                            收货地址
                                        </a>
                                    </div>
                                </td>
                            </tr>
                            {/foreach}
                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body">
                    <div class="page">
                        {$list->render()|raw}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
{include file="public/footer"}
<script>
    layui.use(['laydate', 'form'], function () {
        var laydate = layui.laydate;
        var form = layui.form;
        // 监听全选
        form.on('checkbox(checkall)', function (data) {

            if (data.elem.checked) {
                $('tbody input').prop('checked', true);
            } else {
                $('tbody input').prop('checked', false);
            }
            form.render('checkbox');
        });
    });

    function delAll(argument) {
        var ids = [];
        // 获取选中的id 
        $('tbody input').each(function (index, el) {
            if ($(this).prop('checked')) {
                ids.push($(this).val())
            }
        });
        layer.confirm('确认要删除吗？' + ids.toString(), function (index) {
            //捉到所有被选中的，发异步进行删除
            layer.msg('删除成功', { icon: 1 });
            $(".layui-form-checked").not('.header').parents('tr').remove();
        });
    }
</script>

</html>